﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TodoList
{
    public class TodoListController : MonoBehaviour
    {
        Button AddTodoListButton;
        TodoItem mTodoItem;
        TodosList mTodoList;
        GameObject TodoListContent;

        public GameObject TodoListItem;

        void Start () {
            mTodoList = new TodosList();
            AddTodoListButton = transform.Find("AddTodoListButton").GetComponent<Button>();
            AddTodoListButton.onClick.AddListener(ButtonClick);
            TodoListContent = transform.Find("TodoListContent").gameObject;
        }

        public void ButtonClick()
        {
            mTodoItem = new TodoItem
            {
                title = "title",
                complite = false
            };
            mTodoList.AddTodoItem(mTodoItem);
            Debug.Log(mTodoList.todoList.Count);

            GameObject mTodoListItem = GameObject.Instantiate(TodoListItem);
            mTodoListItem.GetComponent<Text>().text = mTodoItem.title;

            mTodoListItem.transform.SetParent(TodoListContent.transform, false);

        }




    }
}
